<template>
  <div class="main">
    <van-field
      class="input_text"
      readonly
      label="消防器材类型"
      v-model="form.TypeName"
      required
    />
    <van-field
      class="input_text"
      readonly
      label="消防器材编号"
      v-model="form.No"
    />
    <van-field
      class="input_text"
      readonly
      label="所属部门"
      v-model="form.OrgName"
      required
    />
    <van-field
      class="input_text"
      readonly
      label="位置"
      v-model="form.Location"
      required
    />
    <van-field
      class="input_text"
      readonly
      label="规格"
      v-model="form.Specifications"
    />
    <van-field
      class="input_text"
      readonly
      label="数量"
      v-model="form.Cnt"
    />
    <van-field
      class="input_text"
      readonly
      label="最近点检日期"
      :value="getDate(form.CheckDay)"
      required
    />
    <van-field
      class="input_text"
      readonly
      label="下次点检日期"
      :value="getDate(form.NextCheckDay)"
      required
    />
    <van-field
      class="input_text"
      readonly
      label="录入人"
      v-model="form.CreateChnName"
    />
    <van-field
      class="input_text"
      readonly
      label="录入时间"
      :value="getDate(form.CreateDate)"
    />
  </div>
</template>

<script>
import { GetDetail } from "@/api/siteFireEquipment";
import { mapGetters } from "vuex";
import { getDate, getDateTime, getDateDiffs } from "@/utils/getDate";

export default {
  computed: {
    ...mapGetters(["baseUrl", "CompanyCode", "roles"]),
  },
  data() {
    return {
      code: this.$route.query.code,
      id: this.$route.query.id,
      form: {},
    };
  },
  created() {
    if (this.$route.query.code != null) {
      this.getDetail();
    }
  },
  methods: {
    getDate(value) {
      return getDate(value);
    },
    getDateTime(value) {
      return getDateTime(value);
    },
    getDateDiffs(value) {
      if (value != undefined && value != null) {
        if (value > 0) {
          return "逾期" + getDateDiffs(value);
        } else {
          return getDateDiffs(value);
        }
      }
    },
    getDetail() {
      let params = { code: this.code, companyCode: this.CompanyCode };

      GetDetail(params).then((res) => {
        this.form = res.data;
      });
    },
  },
};
</script>

<style lang="less" scoped>
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.block {
  width: 120px;
  height: 120px;
  background-color: #fff;
}
</style>
